﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace GameSchool.Extra
{
    public class UserInfo
    {
        public static Models.Person GetLoggedOnPerson()
        {
            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return Repository.RepositoryMaster.CurrentRepository.Persons.Where(x => x.Username == HttpContext.Current.User.Identity.Name).FirstOrDefault();
            }
            return null;
        }

        public static bool IsAuthenticated
        {
            get 
            {
                return (GetLoggedOnPerson() != null);
            }
        }
    }
}